package com.njbdqn.qiy_person.dao;

import java.util.List;

import org.njbdqn.commons.database.PageHelper;
import org.njbdqn.commons.database.SqlTemplate;

import com.njbdqn.qiy_person.entity.Spacepic;

public class SpacepicDao {

	private SqlTemplate tem;
	private PageHelper ph;
	public SpacepicDao() {
		this.tem = new SqlTemplate();
		this.ph = new PageHelper();
	}
	
	
	public List<Spacepic> listByDynamicid(List<Integer> dynamicid) {
		StringBuilder sb = new StringBuilder();
		sb.append("select * from spacepic where dynamicid in (");
		dynamicid.forEach(id -> {
			sb.append(id);
			sb.append(",");
		});
		String sql = sb.toString();
		sql = sql.replaceFirst("\\,$", ")");
		Object [] arr = new Object[]{dynamicid.size()};
		for (int i = 0; i < arr.length; i++) {
			arr[i] = dynamicid.get(0);
		}
		
		for (int i = 0; i < arr.length; i++) {
			System.out.println(arr[i]);
		}
		
		return tem.resultToArray(sql, arr, Spacepic.class);
	}
	
	public List<Spacepic> resultToList() {
		String sql = "select * from spacepic";
		return tem.resultToArray(sql, new Object[]{}, Spacepic.class);
	}
	
}
